package com.peak.distribution.entity.agent;

import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
import org.hibernate.annotations.LazyToOne;
import org.hibernate.annotations.LazyToOneOption;

import com.peak.distribution.entity.admin.DisUser;
import com.peak.distribution.enums.AgentLevel;
import com.peak.distribution.enums.Constants;
import com.peak.spring.boot.api.entity.DefaultStategyEntity;

import lombok.Getter;
import lombok.Setter;

@Entity
@Table(name = "dis_agent")
@Getter
@Setter
public class DisAgent extends DefaultStategyEntity {

	private static final long serialVersionUID = Constants.DISTRIBUTION_VERSION;
	
	/** 头像 */
	private String headUrl;

	/** 姓名 */
	private String name;
	
	/** 性别 */
	private Boolean sex;

	/** 手机号码 */
	private String mobileNo;

	/** 邮箱 */
	private String email;

	/** QQ号码 */
	private String qq;

	/** 微信号 */
	private String wechat;
	
	/** 签名 */
	private String signature;
	
	/** 代理等级 */
	private AgentLevel level;
	
	/** 加入时间 */
	private Date joinTime;
	
	/** 下级代理人数 */
	private Integer subAgentCount;
	
	/** 审核状态：通过true，未审核或者不通过false */
	private Boolean auditStatus;
	
	/** 用户表 */
	private DisUser user;
	
	/** 父代理 */
	private DisAgent parent;
	
	/** 代理奖金 */
	private DisAgentAward award;

	@ManyToOne
	@JoinColumn(name = "user_id")
	@Fetch(FetchMode.SELECT)
	@LazyToOne(LazyToOneOption.PROXY)
	public DisUser getUser() {
		return user;
	}

	@ManyToOne
	@JoinColumn(name = "parent_id")
	@Fetch(FetchMode.SELECT)
	@LazyToOne(LazyToOneOption.PROXY)
	public DisAgent getParent() {
		return parent;
	}

	@OneToOne(mappedBy = "agent")
	@Fetch(FetchMode.SELECT)
	@LazyToOne(LazyToOneOption.PROXY)
	public DisAgentAward getAward() {
		return award;
	}

	@Enumerated(EnumType.STRING)
	public AgentLevel getLevel() {
		return level;
	}
}
